﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.Infrastructure.Dto.Models.Order;
using WCS.Infrastructure.EFCore;

namespace WCS.Infrastructure.Dto.Response.Order
{
    /// <summary>
    /// 订单响应对象
    /// </summary>
    public class OrderResponseDto
    {
        /// <summary>
        /// 订单ID
        /// </summary>
        public string? Id { get; set; }

        /// <summary>
        /// 订单编号
        /// </summary>
        public string? OrderCode { get; set; }

        /// <summary>
        /// 订单金额
        /// </summary>
        public long? OrderAmount { get; set; }

        /// <summary>
        /// 订单类型
        /// </summary>
        public int? OrderType { get; set; }

        /// <summary>
        /// 收款码ID
        /// </summary>
        public string? CodeId { get; set; }

        /// <summary>
        /// 门店ID
        /// </summary>
        public string? StoreId { get; set; }

        /// <summary>
        /// 商户ID
        /// </summary>
        public string? MerchantId { get; set; }

        /// <summary>
        /// 支付设备ID
        /// </summary>
        public string? DeviceId { get; set; }

        /// <summary>
        /// 费率
        /// </summary>
        public decimal? Rate { get; set; }

        /// <summary>
        /// 手续费
        /// </summary>
        public long? Commission { get; set; }

        /// <summary>
        /// 优惠券实例ID
        /// </summary>
        public string? CouponInstanceId { get; set; }

        /// <summary>
        /// 优惠金额
        /// </summary>
        public long? DiscountAmount { get; set; }

        /// <summary>
        /// 结算金额
        /// </summary>
        public long? SettlementAmount { get; set; }

        /// <summary>
        /// 平台服务费率（优惠券使用产生）
        /// </summary>
        public decimal? PlatformServiceFeeRate { get; set; }

        /// <summary>
        /// 平台服务费（优惠券使用产生）
        /// </summary>
        public long? PlatformServiceFee { get; set; }

        /// <summary>
        /// 支付时间
        /// </summary>
        public DateTime? PaymentTime { get; set; }

        /// <summary>
        /// 支付状态(0=未支付，1=支付成功​，2=支付失败​​，3=支付超时​​)
        /// </summary>
        public int? PaymentStatus { get; set; }

        /// <summary>
        /// 优惠券推荐抽成金额
        /// </summary>
        public long? RecommendationCommissionAmount { get; set; }

        /// <summary>
        /// 推荐商户ID
        /// </summary>
        public string? RecommendMerchantId { get; set; }

        /// <summary>
        /// 支付用户ID
        /// </summary>
        public string? UserId { get; set; }

        /// <summary>
        /// 小程序OpenID
        /// </summary>
        public string? OpenId { get; set; }

        /// <summary>
        /// 分账协议ID
        /// </summary>
        public string? DividedAgreementId { get; set; }

        /// <summary>
        /// 订单快照
        /// </summary>
        public string? OrderSnapshot { get; set; }

        /// <summary>
        /// 累计退款金额
        /// </summary>
        public long? TotalRefundAmount { get; set; }

        /// <summary>
        /// 退款次数
        /// </summary>
        public int? RefundCount { get; set; }

        /// <summary>
        /// 退款状态(0=未退款，1=部分退款，2=全额退款)
        /// </summary>
        public int? RefundStatus { get; set; }

        /// <summary>
        /// 退款处理状态(0=无退款进行中，1=有退款进行中)
        /// </summary>
        public int? RefundProcessStatus { get; set; }

        /// <summary>
        /// 退款时间
        /// </summary>
        public DateTime? RefundTime { get; set; }

        /// <summary>
        /// 最后退款时间
        /// </summary>
        public DateTime? LastRefundTime { get; set; }

        /// <summary>
        /// 是否结算
        /// </summary>
        public int? IsSettlement { get; set; }

        /// <summary>
        /// 结算日期(根据结算周期算出 只取日期部分 时间为 00:00:00)
        /// </summary>
        public DateTime? SettlementDate { get; set; }

        /// <summary>
        /// 结算时间
        /// </summary>
        public DateTime? SettlementTime { get; set; }

        /// <summary>
        /// 是否分账
        /// </summary>
        public int? IsDivided { get; set; }

        /// <summary>
        /// 分账日期(根据分账周期算出 只取日期部分 时间为 00:00:00)
        /// </summary>
        public DateTime? DividedDate { get; set; }

        /// <summary>
        /// 分账时间
        /// </summary>
        public DateTime? DividedTime { get; set; }


        #region 易票联对接字段

        ///// <summary>
        ///// 版本号
        ///// </summary>
        //public string? Version { get; set; }

        /// <summary>
        /// 商户订单号
        /// </summary>
        public string OutTradeNo { get; set; } = null!;

        ///// <summary>
        ///// 商户编号
        ///// </summary>
        //public string CustomerCode { get; set; } = null!;

        ///// <summary>
        ///// 用户终端 IP
        ///// </summary>
        //public string? ClientIp { get; set; }

        ///// <summary>
        ///// 商品订单信息
        ///// </summary>
        //public string? OrderInfo { get; set; }

        /// <summary>
        /// 支付金额，单位为分
        /// </summary>
        public long PayAmount { get; set; }

        ///// <summary>
        ///// 支付币种：默讣CNY人民币 
        ///// </summary>
        //public string PayCurrency { get; set; } = null!;

        ///// <summary>
        ///// 是否禁止信用卡支付
        ///// </summary>
        //public string? NoCreditCards { get; set; }

        ///// <summary>
        ///// 支付结果通知地址
        ///// </summary>
        //public string NotifyUrl { get; set; } = null!;

        ///// <summary>
        ///// 商户支付结果展示地址
        ///// </summary>
        //public string? RedirectUrl { get; set; }

        ///// <summary>
        ///// 商户备注
        ///// </summary>
        //public string? AttachData { get; set; }

        ///// <summary>
        ///// 交易开始时间
        ///// </summary>
        //public string TransactionStartTime { get; set; } = null!;

        ///// <summary>
        ///// 交易超时时间
        ///// </summary>
        //public string? TransactionEndTime { get; set; }

        /// <summary>
        /// 支付方式
        /// </summary>
        public string? PayMethod { get; set; }

        /// <summary>
        /// 子商户公众号appid
        /// </summary>
        public string? SubAppId { get; set; }

        /// <summary>
        /// 支付宝用户ID
        /// </summary>
        public string? BuyerId { get; set; }

        /// <summary>
        /// 上游商户号
        /// </summary>
        public string? ChannelOrder { get; set; }

        /// <summary>
        /// 易票联订单号
        /// </summary>
        public string? TransactionNo { get; set; }

        ///// <summary>
        ///// 分期可用渠道
        ///// </summary>
        //public string? EnablePayChannels { get; set; }

        ///// <summary>
        ///// 分期期数
        ///// </summary>
        //public int? InstalmentsNum { get; set; }

        ///// <summary>
        ///// 支付宝门店编号
        ///// </summary>
        //public string? AlipayStoreCode { get; set; }

        ///// <summary>
        ///// 支付宝门店ID
        ///// </summary>
        //public string? AlipayStoreId { get; set; }

        ///// <summary>
        ///// 付款人信息（微信、支付宝支付时有效）
        ///// </summary>
        //public string? ExtUserInfo { get; set; }

        ///// <summary>
        ///// 终端信息
        ///// </summary>
        //public string? TerminalInfo { get; set; }

        ///// <summary>
        ///// 地区信息
        ///// </summary>
        //public string AreaInfo { get; set; } = null!;

        ///// <summary>
        ///// 扩展参数
        ///// </summary>
        //public string? ExtendParams { get; set; }

        ///// <summary>
        ///// 优惠编码
        ///// </summary>
        //public string? Coupons { get; set; }

        ///// <summary>
        ///// 随机字符串
        ///// </summary>
        //public string NonceStr { get; set; } = null!;

        /// <summary>
        /// 可退款金额
        /// </summary>
        public long? RefundableAmount { get; set; }
        #endregion

        /// <summary>
        /// 扩展属性
        /// </summary>
        public string? ExtraProperties { get; set; }

        /// <summary>
        /// 并发标记
        /// </summary>
        public string? ConcurrencyStamp { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreationTime { get; set; }

        /// <summary>
        /// 创建人ID
        /// </summary>
        public string? CreatorId { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>
        public DateTime? LastModificationTime { get; set; }

        /// <summary>
        /// 最后修改者ID
        /// </summary>
        public string? LastModifierId { get; set; }

        /// <summary>
        /// 是否删除
        /// </summary>
        public bool? IsDeleted { get; set; }

        /// <summary>
        /// 删除者ID
        /// </summary>
        public string? DeleterId { get; set; }

        /// <summary>
        /// 删除时间
        /// </summary>
        public DateTime? DeletionTime { get; set; }



        #region 订单快照字段

        /// <summary>
        /// 收款码编号
        /// </summary>
        public string? Code { get; set; }

        /// <summary>
        /// 收款码名称
        /// </summary>
        public string? CodeName { get; set; }

        /// <summary>
        /// 门店编号
        /// </summary>
        public string? StoreCode { get; set; }

        /// <summary>
        /// 门店名称
        /// </summary>
        public string? StoreName { get; set; }


        /// <summary>
        /// 商户编号
        /// </summary>
        public string? MerchantCode { get; set; }

        /// <summary>
        /// 商户名称
        /// </summary>
        public string? MerchantName { get; set; }

        /// <summary>
        /// 协议编号
        /// </summary>
        public string? AgreementCode { get; set; }

        /// <summary>
        /// 协议名称
        /// </summary>
        public string? AgreementName { get; set; }

        /// <summary>
        /// 协议详情列表
        /// </summary>
        public List<AgreementDetail>? AgreementDetails { get; set; } = new List<AgreementDetail>();

        /// <summary>
        /// 分账周期
        /// </summary>
        public int? DividedCycle { get; set; }

        /// <summary>
        /// 结算周期
        /// </summary>
        public int? SettlementCycle { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime SnapshotTime { get; set; }

        #endregion

        /// <summary>
        /// 退款记录列表
        /// </summary>
        public List<OrderRefundRecordResponseDto> orderRefundRecords { get; set; } = new List<OrderRefundRecordResponseDto>();
    }
}
